package com.hsm7;

import sun.reflect.generics.tree.Tree;

import java.util.Comparator;
import java.util.TreeSet;

public class TestStudent {
    public static void main(String[] args) {
    //利用外部比较器，自己创建
        Comparator<Student> c = new BiJiao1();
        /*Comparator<Student> c1 = new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return 0;
            }
        }*/
        //创建的时候指定外部构造器（这个外部比较器与HashSet的比较器不同）
        TreeSet<Student> ts = new TreeSet<>(c);
        ts.add(new Student(20,"hsm"));
        ts.add(new Student(25,"cy"));
        ts.add(new Student(21,"ada"));
        ts.add(new Student(28,"ada"));
        ts.add(new Student(20,"ada"));
        System.out.println(ts.size());
        System.out.println(ts);

    }
}
